// app/api/branches/[branch]/[year]/months/route.js import { NextResponse } from "next/server"; import { listMonths } from "@/lib/storage"; /** * GET /api/branches/[branch]/[year]/months * * Returns the list of month folders for a given branch and year. * Example: /api/branches/NL01/2024/months → { months: ["01", "02", ...] } */ export async function GET(request, ctx) { const { branch, year } = await ctx.params; console.log("[/api/branches/[branch]/[year]/months] params:", { branch, year, }); if (!branch || !year) { return NextResponse.json( { error: "branch oder year fehlt" }, { status: 400 } ); } try { const months = await listMonths(branch, year); return NextResponse.json({ branch, year, months }); } catch (error) { console.error("[/api/branches/[branch]/[year]/months] Error:", error); return NextResponse.json( { error: "Fehler beim Lesen der Monate: " + error.message }, { status: 500 } ); } }